-
Notifications
You must be signed in to change notification settings - Fork 117
fix: prevent fallback to legacy store when migrating #955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent fallback to legacy store when migrating #955
Conversation
WalkthroughThe Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
if err != nil { | ||
return nil, nil, fmt.Errorf("checking if bucket is up to date: %w", err) | ||
} | ||
|
||
return ledgerstore.NewDefaultStoreAdapter(isUpToDate, store), l, nil | ||
return ledgerstore.NewDefaultStoreAdapter(lastVersion >= 26, store), l, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magical number, corresponding to the migration 25.
The migration 25 was introduced in v2.2.0 of the ledger.
So checking for this version is enough to declare the database is up to date to use the new store.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
internal/storage/driver/adapters.go (2)
23-26
: Update error message to reflect the actual operation.The logic change from
IsUpToDate
toGetLastVersion
is correct and aligns with the PR objective. However, the error message on line 25 still refers to "checking if bucket is up to date" when we're now getting the last version.Apply this diff to update the error message:
- return nil, nil, fmt.Errorf("checking if bucket is up to date: %w", err) + return nil, nil, fmt.Errorf("getting bucket last version: %w", err)
28-28
: Consider extracting the version threshold as a named constant.The logic
lastVersion >= 26
correctly determines when the store is up-to-date enough to avoid legacy fallback, which aligns with the PR objective. However, the magic number26
should be extracted as a named constant for better maintainability.Consider adding a constant at the package level:
+const MinStoreVersionForNewAdapter = 26 + func (d *DefaultStorageDriverAdapter) OpenLedger(ctx context.Context, name string) (ledgercontroller.Store, *ledger.Ledger, error) {Then update the comparison:
- return ledgerstore.NewDefaultStoreAdapter(lastVersion >= 26, store), l, nil + return ledgerstore.NewDefaultStoreAdapter(lastVersion >= MinStoreVersionForNewAdapter, store), l, nil
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/storage/driver/adapters.go
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/storage/driver/adapters.go (1)
internal/storage/ledger/legacy/adapters.go (1)
NewDefaultStoreAdapter
(345-351)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Tests
- GitHub Check: Dirty
No description provided.